#!/usr/bin/env bash
# bash <(curl -sLk https://raw.githubusercontent.com/u-on/script/main/shell/libstdc++.sh)

function Download() {
    local downloadUrl githubUrls
    downloadUrl=$1
    githubUrls=(
        https://github.com.cnpmjs.org/
        https://github.com/
        https://hub.fastgit.org/
    )

    if [ -z "$2" ]; then
        for i in "${githubUrls[@]}"; do
            echo "Download From : $i$downloadUrl"
            if curl -fLOk --retry 1 "$i$downloadUrl"; then
                break
            fi

        done
    else
        for i in "${githubUrls[@]}"; do
            echo "Download From : $i$downloadUrl"
            if curl -fLk -o "$2" --retry 1 "$i$downloadUrl"; then
                break
            fi

        done

    fi

}

Download "u-on/src/blob/page/linux/lib/libstdc++.so.6"
# Download "u-on/src/blob/page/linux/lib/libstdc%2B%2B.so.6" "libstdc++.so.6"

if [ ! -f "/lib/libstdc++.so.6" ]; then
    cp libstdc++.so.6 /lib/libstdc++.so.6
else
    echo enable
fi
rm -f libstdc++.so.6
